Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request introduces localized content hashing for Angular builds, implementing a new utility createLocalizedOutputHasher to rename localized browser scripts based on content and dependency changes. Feedback on the changes includes a critical correction to the worker script regular expressions to support lowercase and mixed-case hashes, as well as a recommendation to resolve variable shadowing of path in the build execution file.
4d935bc to
bb6e7f6
Compare
|
Thanks for working on this and looking into #30675! After reviewing the approach, we don't want to introduce a post-bundler AST/regex pass that re-parses emitted bundles and rewrites chunk filenames per locale. The We're going to close this PR as this would need a different architectural approach within the bundler/inlining pipeline itself. Thanks again for your contribution! |
PR Checklist
PR Type
What is the current behavior?
The application builder adds a digest of the translation files to every JavaScript bundle. Editing one locale can give unrelated chunks new URLs in every locale, forcing browsers to download them again.
Fixes #30675.
What is the new behavior?
For one-shot browser builds with bundle hashing enabled, compute names after localization. A changed bundle gets a new URL, and bundles that reference it get updated URLs. Unchanged bundles retain their URLs. The dependency graph comes from the esbuild/Rolldown output metadata; JavaScript is parsed when references need to be rewritten or to find worker URLs that are absent from the graph.
Watch, server builds, and builds with custom code plugins keep the existing hashing path.
Does this PR introduce a breaking change?
Measurements and verification
Chromium 153, warm browser cache. Changed one French XLF message used by a lazy chunk, switched deployments on the same origin, and opened the page and one independent lazy chunk. JS used immutable cache headers; HTML used
no-store. All three runs per locale and variant gave the same results. Bytes are Brotli response bodies, excluding headers.Build time. Synthetic Angular app with 240 lazy routes, three locales and 254 JS outputs per locale. Five alternating pairs per mode, after a warm-up pair; CLI disk cache disabled. The full build compares this PR with upstream
main. The rehash stage compares the metadata approach with the initial implementation that parsed JavaScript to build the graph.main(range)The stage timings are separate instrumented runs, including graph construction. These figures describe the test fixtures, not production CDN traffic or general build performance.
Validation. Ran 50 i18n tests and the localized-hashes e2e scenario locally, including sourcemap references and SHA-384 integrity for the emitted entry bundle. Checked localized workers in Chromium with esbuild and Rolldown. The initial
--watchbuild and two rebuilds after editing a lazy TypeScript module produced identical filenames and SHA-256 digests for the entry bundle, lazy chunk and HTML onmainand the PR branch. Each rebuild updated the import and removed the old chunk.